/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
using System;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace ELE.EnterpriseLibrary.Data.Configuration
{
  /// <summary>
  /// Configuration data for defining a query builder.
  /// <para>For example:</para>
  /// <code>
  ///  &lt;queryBuilders>
  ///    &lt;add  name="Generic" type="ELE.EnterpriseLibrary.Data.GenericSqlQueryBuilder, ELE.EnterpriseLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"  default="true"/>
  ///  &lt;/queryBuilders>
  /// </code>
  /// </summary>
  public class QueryBuilderData : NamedConfigurationElement
  {
    private const string typeProperty = "type";
    private const string defaultProperty = "default";
    /// <summary>
    /// Default empty constructor.
    /// </summary>
    public QueryBuilderData() { }
    /// <summary>
    /// Constructor that takes the name to identify the query builder.
    /// </summary>
    /// <param name="name"></param>
    public QueryBuilderData(string name) : base(name) { }
    /// <summary>
    /// The string that defines the type to use to create the query builder.
    /// <para>The type must:
    /// <list type="bullet">
    ///   <item>Have a no argument constructor</item>
    ///   <item>Implement <see cref="ISqlQueryBuilder"/></item>
    /// </list>
    /// </para>
    /// </summary>
    [ConfigurationProperty(typeProperty, IsRequired = true)]
    public string Type
    {
      get { return (string)base[typeProperty]; }
      set { base[typeProperty] = value; }
    }
    /// <summary>
    /// Defines this query builder as he default if set to true.
    /// </summary>
    [ConfigurationProperty(defaultProperty, IsRequired = false, DefaultValue=false)]
    public bool Default
    {
      get { return (bool)base[defaultProperty]; }
      set { base[defaultProperty] = value; }
    }
  }
}
